<?php

if (!defined('NV_ADMIN')) {
die ("Access Denied");
}



global $prefix, $db;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Nvmenu'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, email, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
$auth_user = 1;	
}
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {

include_once("language/nvmenu-".$currentlang.".php");

function get_subid($subid, $title, $k) {
global $adminfile, $prefix, $db;

$sql = "SELECT * FROM ".$prefix."_nvmenu ORDER BY weight, BINARY title";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$menu_cat[$row['id']] = $row;
}

if((isset($menu_cat[$subid]['id'])) AND ($menu_cat[$subid]['sub_id'] != $subid)) {

if ($menu_cat[$subid]['title'] != '') {
if($k == 1) {
$title = $menu_cat[$subid]['title']." | ".$title;
} else {
$title = "<a href=".$adminfile.".php?op=nvmenu_main&sub_id=".$menu_cat[$subid]['id'].">".$menu_cat[$subid]['title']."</a> | ".$title;
}
}

if ($menu_cat[$subid]['sub_id'] != 0) {
$title = get_subid($menu_cat[$subid]['sub_id'], $title);
}

}

return $title;

}

function get_subid2($subid,$id) {
    global $prefix,$db;
    $cid = intval($cid);
    list($sub_id) = $db->sql_fetchrow($db->sql_query("select sub_id from ".$prefix."_nvmenu where id='$subid'"));
    if ($sub_id == 0) $a = 1;
    elseif ($sub_id == $id) $a = 0;
    else $a=get_subid2($sub_id,$id);
    return $a;
}

function nvmenu($subid) {
global $prefix, $db;
$sql = "SELECT * FROM ".$prefix."_nvmenu ORDER BY sub_id, weight";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if ($row['sub_id'] != '0') { $title = get_subid($row['sub_id'], $row['title'], 1); }
else { $title = $row['title']; }
if($row['id'] == $subid) { $sel = "selected"; } else { $sel = ""; }
$nvmenu .= "<option value='$row[id]' $sel>$title</option>";
}
return $nvmenu;
}

function menu_adds($sub_id) {
    global $adminfile, $multilingual, $currentlang, $prefix, $db;

    OpenTable();
    echo "<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\"><tr><td>";
    $themmenu .= "<form method='POST' action='".$adminfile.".php' enctype='multipart/form-data'>";
    $themmenu .= "<tr><td><b>"._MENUNAME."</b></td>";
    $themmenu .= "<td><input type='text' name='title' size='40'></td></tr>";
    $themmenu .= "<tr><td colspan='2' style='text-align: center'><hr><b>"._MENULINKNOTE1."</b></td></tr>";
    $sqlmod = "SELECT title FROM ".$prefix."_modules ORDER BY title";
    $resultmod = $db->sql_query($sqlmod);
    $themmenu .= "<tr><td><b>"._MODULES."</b></td><td><select name='in_module'>";
    $themmenu .= "<option value=''>"._NO."</option>";
    $themmenu .= "<option value='home'>"._HOME."</option>";
    while(list($modtitle) = $db->sql_fetchrow($resultmod)) {
           $themmenu .= "<option value='$modtitle'>$modtitle</option>";
   }
   $themmenu .= "<option value='adm'>"._ADMINMENU."</option>";
   $themmenu .= "</select></td></tr>";
   $themmenu .= "<tr><td><b>"._MODCATID."</b></td><td>";
   $themmenu .= "<input type='text' name='in_catid' size='5'></td></tr>";
   $themmenu .= "<tr><td><b>"._MENULINK."</b></td><td>";
   $themmenu .= "<input type='text' name='addlink' size='40'></td></tr>";
   $themmenu .= "<tr><td colspan='2' style='text-align: justify'>"._MENULINKNOTE2."</td></tr>";
   $themmenu .= "<tr><td colspan='2' style='text-align: center'><hr><b>"._MENULINKNOTE3."</b></td></tr>";
   $themmenu .= "<tr><td><b>"._MENUURL."</b></td><td>";
   $themmenu .= "<input type='text' name='urlmenu' size='40'></td></tr>";
   $themmenu .= "<tr><td colspan='2' style='text-align: center'><hr></td></tr>";
   $themmenu .= "<tr><td><b>"._MCATDESCRIPTION."</b></td>";
   $themmenu .= "<td><input type='text' name='cdescription' size='40'></td></tr>";
   $themmenu .= "<tr><td><b>"._MENUPARENT."</b></td>";
   $themmenu .= "<td><select name='sub_id'>";
   $themmenu .= "<option value='0'><b>"._MENUNOPARENT."</b></option>";
   $themmenu .= nvmenu($sub_id);
   $themmenu .= "</select></td></tr>";
          
   if ($multilingual == 1) {
   $themmenu .= "<tr><td><b>"._LANGUAGE.":</b></td>";
   $themmenu .= "<td><select name='view_lang'>";
   $themmenu .= "<option value=''>"._ALL."</option>";
   $themmenu .= select_language($currentlang);
   $themmenu .= "</select></td>";
   $themmenu .= "</tr>";
   } else {
   $themmenu .= "<input type='hidden' name='view_lang' value='$language'>";
   }
   $themmenu .= "<tr><td><b>"._MENUTARGET."</b></td>";
   $themmenu .= "<td><input type='checkbox' name='target' value='1'></td></tr>";
   $themmenu .= "<tr><td><b>"._VIEWPRIV."</b></td>";
   $themmenu .= "<td><select name='view'>";
   $themmenu .= "<option value='0'>"._MVALL."</option>";
   $themmenu .= "<option value='1'>"._MVUSERS."</option>";
   $themmenu .= "<option value='2'>"._MVADMIN."</option>";
   $themmenu .= "<option value='3'>"._MVANON."</option>";
   $themmenu .= "<option value='4'>"._MVGROUPS."</option>";
   $themmenu .= "</select></td></tr>";
   $themmenu .= "<tr><td><b>"._WHATGROUPS."</b></td>";
   $themmenu .= "<td><select name='groups[]' multiple size='5'>";
   $groupsResult = $db->sql_query("select gid, gname from ".$prefix."_nsngr_groups WHERE gname!='Anonymous'");
   while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) {
   $themmenu .= "<OPTION VALUE='$gid'>$gname</option>";
   }
   $themmenu .= "</select></td></tr>";
   $themmenu .= "<tr><td colspan='2' align='center'>";
   $themmenu .= "<input type='hidden' name='op' value='menu_addsave'>";
   $themmenu .= "<input type='submit' value='"._ADDMENUNV."'></td>";
   $themmenu .= "</tr></form>";
   echo $themmenu;
   //javapopub(_ADDNVMENU, $themmenu);
   echo"</td></tr></table>";
   CloseTable();
}

function fixweightsubmenu($id,$weight) {
global $prefix, $db;
$result = $db->sql_query("select * from ".$prefix."_nvmenu where sub_id='$id' order by weight");
while($row = $db->sql_fetchrow($result)) {
	$weight++;
	$db->sql_query("update ".$prefix."_nvmenu set weight='$weight' where id='$row[id]'");
	if($row['submenu']!="") {
	$weight = fixweightsubmenu($row['id'],$weight);
	}
}

return $weight;
}

function fixweightcatmenu() {
    global $prefix, $db;
    $resultweightmenu = $db->sql_query("select id, submenu from ".$prefix."_nvmenu where sub_id='0' order by weight");
    $weight = 0;
    while($row = $db->sql_fetchrow($resultweightmenu)) {
        $id = intval($row['id']);
        $submenu = $row['submenu'];
        $weight++;
        $db->sql_query("update ".$prefix."_nvmenu set weight='$weight' where id='$id'");
        if($submenu != "") {
        $weight = fixweightsubmenu($id,$weight);
        }
    }
}


function menu_addsave() {
global $db, $prefix;
$title = trim(stripslashes($_POST['title']));
$in_module = trim(stripslashes($_POST['in_module']));
$in_catid = intval($_POST['in_catid']);
$addlink = trim(stripslashes($_POST['addlink']));
$urlmenu = trim(stripslashes($_POST['urlmenu']));
$cdescription = trim(stripslashes($_POST['cdescription']));
$sub_id = intval($_POST['sub_id']);
$view = intval($_POST['view']);
$groups = $_POST['groups'];
$target = trim(stripslashes($_POST['target']));
$view_lang = $_POST['view_lang'];
if($in_module!="") { $urlmenu = ""; }
if($in_module=="") { $in_catid = ""; $addlink = ""; }
if($view == 4) { $ingroups = implode("-",$groups); }
if($view < 4) { $ingroups = ""; }
$weightresult = $db->sql_query("SELECT weight FROM ".$prefix."_nvmenu WHERE sub_id='$sub_id' ORDER BY weight DESC");
$row = $db->sql_fetchrow($weightresult);
$weight = $row['weight'];
$weight = $weight+1;
if($title != "") {
list($newest_uid) = $db->sql_fetchrow($db->sql_query("SELECT max(id) AS newest_uid FROM ".$prefix."_nvmenu"));
if ($newest_uid == "-1") { $new_uid = 1; } else { $new_uid = $newest_uid+1; }
$db->sql_query("INSERT INTO ".$prefix."_nvmenu (id, title, in_module, in_catid, addlink, urlmenu, cdescription, sub_id, weight, view, groups, submenu, target, view_lang) VALUES ('$new_uid', '$title', '$in_module', '$in_catid', '$addlink', '$urlmenu', '$cdescription', '$sub_id', '$weight', '$view', '$ingroups', '', '$target', '$view_lang')");
if($sub_id != '0') {
$resultsub = $db->sql_query("SELECT submenu FROM ".$prefix."_nvmenu WHERE id='$sub_id'");
$rowsub = $db->sql_fetchrow($resultsub);
$submenu = $rowsub['submenu'];
if($submenu == "") { $xsubmenu = "$new_uid"; }
else { $xsubmenu = "$submenu|$new_uid"; }
$db->sql_query("UPDATE ".$prefix."_nvmenu SET submenu = '$xsubmenu'  WHERE id = '$sub_id'");
}
fixweightcatmenu();
}
Header("Location: $_SERVER[HTTP_REFERER]");
}

function menu_edit() {
global $adminfile, $prefix, $db, $multilingual, $language;
    $id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0;
    $catnum = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM ".$prefix."_nvmenu WHERE id = '$id'"));
    if ($catnum[0] == 0) {
    	header("Location: ".$adminfile.".php");
    }
    $result = $db->sql_query("SELECT * FROM ".$prefix."_nvmenu WHERE id = '$id'");
    $row = $db->sql_fetchrow($result);
    include("../header.php");
    OpenTable();
    echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b></center>";
    CloseTable();
    echo "<center><br><b>"._EDITMENUNV."</b><br><br><table border=\"0\" style=\"border-collapse: collapse\">\n";
    echo "<form method='POST' action='".$adminfile.".php' enctype='multipart/form-data'>";
    echo "<tr><td><b>"._MENUNAME.":</b></td><td><input type='text' name='title' size='80' value='$row[title]'></td></tr>";
    echo "<tr><tr><td colspan='2'><hr><b>"._MENULINKNOTE1.":</b></td></tr>";
    $sqlmod = "SELECT title FROM ".$prefix."_modules ORDER BY title";
    $resultmod = $db->sql_query($sqlmod);
    echo "<tr><td><b>"._MODULES.":</b></td><td><select name='in_module'>";
    echo "<option value=''>"._NO."</option>";
    $sel = "";
    if($row['in_module'] == "home") {
    	$sel = "selected";
    }
    echo "<option value='home' $sel>"._HOME."</option>";

    while(list($modtitle) = $db->sql_fetchrow($resultmod)) {
    	$sel = "";
    	if($row['in_module'] == "$modtitle") {
    	$sel = "selected";
    	}
    echo "<option value='$modtitle' $sel>$modtitle</option>";
   }
   $sel = "";
   if($row['in_module'] == "adm") {
   $sel = "selected";
  }
   echo "<option value='adm' $sel>"._ADMINMENU."</option>";
   echo "</select></td></tr>";
   echo "<tr><td><b>"._MODCATID.":</b></td><td><input type='text' name='in_catid' size='5' value='$row[in_catid]'></td></tr>";
   echo "<tr><td><b>"._MENULINK.":</b></td><td><input type='text' name='addlink' size='80' value='$row[addlink]'></td></tr>";
   echo "<tr><td colspan='2'>"._MENULINKNOTE2."</td></tr>";
   echo "<tr><td colspan='2'><hr><b>"._MENULINKNOTE3.":</b></td></tr>";
   echo "<tr><td><b>"._MENUURL.":</b></td><td><input type='text' name='urlmenu' size='80' value='$row[urlmenu]'></td></tr>";
   echo "<tr><td colspan='2'><hr></td></tr>";
   echo "<tr><td><b>"._MCATDESCRIPTION.":</b></td>";
   echo "<td><input type='text' name='cdescription' size='80' value='$row[cdescription]'></td></tr>";
    echo "<tr><td><b>"._MENUPARENT.":</b></td>";
    echo "<td><select name=\"sub_id\">\n";
    echo "<option value='0'>"._MENUNOPARENT."</option>";
    $resultparentid = $db->sql_query("select id, title, sub_id from ".$prefix."_nvmenu where id != '$id' AND sub_id!='$id' ORDER BY sub_id, weight");
          while (list($id2, $title2, $subid2) = $db->sql_fetchrow($resultparentid)) {
                   if ($subid2==0) { $a = 1; }
                   else { $a = get_subid2($subid2,$id); }
                   if ($a==1) {
                   	if ($subid2!=0) { $title=get_subid($subid2,$title2); } else { $title = $title2; }
                   echo "<option value=\"$id2\"";
                   if($id2 == $row['sub_id']) echo " selected";
                   echo">$title</option>";
                  }
          }
          echo "</select></td></tr>";
   
   echo "<tr><td><b>"._LANGUAGE.":</b></td>";
   echo "<td><select name='view_lang'>";
   echo "<option value=''>"._ALL."</option>";
   echo select_language($row['view_lang']);
   echo "</select></td></tr>";
   echo "<tr><td><b>"._MENUTARGET."</b></td>";
   echo "<td><input type='checkbox' name='target' value='1'";
   if($row['target'] == 1) echo " checked";
   echo"></td></tr>";
   $view_array = array(_MVALL,_MVUSERS,_MVADMIN,_MVANON,_MVGROUPS);
   echo "<tr><td><b>"._VIEWPRIV."</b></td>";
   echo "<td><select name='view'>";
   for($i=0;$i < 5;$i++) {
   $sel="";
   if($row['view'] == $i) {
   $sel = "selected";
  }
   echo "<option value='$i' $sel>$view_array[$i]</option>";
  }
  echo "</select></td></tr>";
  echo "<tr><td><b>"._WHATGROUPS."</b></td>";
  echo "<td><select name='groups[]' multiple size='5'>";
  $ingroups = explode("-",$row['groups']);
  $groupsResult = $db->sql_query("select gid, gname from ".$prefix."_nsngr_groups");
  while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) {
	if(in_array($gid,$ingroups)) { $sel = " selected"; } else { $sel = ""; }
	echo "<OPTION VALUE='$gid'$sel>$gname</option>";
	}
   echo "</select></td></tr>";
   echo "<tr><td colspan='2' align='center'>";
   echo "<input type='hidden' name='id' value='$row[id]'>";
   echo "<input type='hidden' name='ol_subid' value='$row[sub_id]'>";
   echo "<input type='hidden' name='weight' value='$row[weight]'>";
   echo "<input type='hidden' name='submenu' value='$row[submenu]'>";
   echo "<input type='hidden' name='op' value='menu_editsave'>";
   echo "<input type='submit' value='"._EDITMENUNV2."'></td>";
   echo "</tr></form></table></center>";
    include("../footer.php");
}

function menu_editsave() {
global $adminfile, $db, $prefix;
$id = intval($_POST['id']);
$catnum = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM ".$prefix."_nvmenu WHERE id = '$id'"));
    if ($catnum[0] == 0) {
    	header("Location: ".$adminfile.".php");
}
$title = trim(stripslashes($_POST['title']));
$in_module = trim(stripslashes($_POST['in_module']));
$in_catid = intval($_POST['in_catid']);
$addlink = trim(stripslashes($_POST['addlink']));
$urlmenu = trim(stripslashes($_POST['urlmenu']));
$cdescription = trim(stripslashes($_POST['cdescription']));
$sub_id = intval($_POST['sub_id']);
$weight = intval($_POST['weight']);
$view = intval($_POST['view']);
$groups = $_POST['groups'];
$submenu = $_POST['submenu'];
$target = trim(stripslashes($_POST['target']));
$view_lang = $_POST['view_lang'];
$ol_subid = intval($_POST['ol_subid']);

if($in_module!="") { $urlmenu = ""; }
if($in_module=="") { $in_catid = ""; $addlink = ""; }

if($view == 4) { $ingroups = implode("-",$groups); }
if($view < 4) { $ingroups = ""; }

if($ol_subid != $sub_id) {
$weightresult = $db->sql_query("SELECT submenu, weight FROM ".$prefix."_nvmenu WHERE sub_id='$sub_id' ORDER BY weight DESC");
$row = $db->sql_fetchrow($weightresult);
$weight = $row['weight'];
$weight = $weight+1;
}
if($title != "") {
$db->sql_query("UPDATE ".$prefix."_nvmenu SET title='$title', in_module='$in_module', in_catid='$in_catid', addlink='$addlink', urlmenu='$urlmenu', cdescription='$cdescription', sub_id='$sub_id', weight='$weight', view='$view', groups='$ingroups', submenu='$submenu', target='$target', view_lang='$view_lang'  WHERE id = '$id'");

if($ol_subid != $sub_id AND $sub_id != '0') {
$resultsub = $db->sql_query("SELECT id, submenu FROM ".$prefix."_nvmenu WHERE id='$sub_id'");
$rowsub = $db->sql_fetchrow($resultsub);
$id2 = $rowsub['id'];
$submenu2 = $rowsub['submenu'];
if($submenu2 == "") { $xsubmenu = "$id"; }
else { $xsubmenu = "$submenu2|$id"; }
$db->sql_query("UPDATE ".$prefix."_nvmenu SET submenu = '$xsubmenu'  WHERE id = '$id2'");
}
if($ol_subid != $sub_id AND $ol_subid!='0') {
$resultsub3 = $db->sql_query("SELECT id, submenu FROM ".$prefix."_nvmenu WHERE id='$ol_subid'");
$rowsub3 = $db->sql_fetchrow($resultsub3);
$id3 = $rowsub3['id'];
$submenu3 = $rowsub3['submenu'];
$submenu3_array = explode("|",$submenu3);
$xsubmenu3 = "";
for($i=0;$i < sizeof($submenu3_array);$i++) {
if($submenu3_array[$i]!="$id") {
if($xsubmenu3=="") { $xsubmenu3 .= "$submenu3_array[$i]"; }
else { $xsubmenu3 .= "|$submenu3_array[$i]"; }
}
}
$db->sql_query("UPDATE ".$prefix."_nvmenu SET submenu = '$xsubmenu3'  WHERE id = '$id3'");
}
fixweightcatmenu();
}
Header("Location: ".$adminfile.".php?op=nvmenu_main");
}

function menu_del() {
global $adminfile, $db, $prefix;
$id = intval($_GET['id']);
$catnum = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM ".$prefix."_nvmenu WHERE id = '$id'"));
    if ($catnum[0] == 0) {
    	header("Location: ".$adminfile.".php");
}
$result = $db->sql_query("SELECT submenu, sub_id FROM ".$prefix."_nvmenu WHERE id='$id'");
$row = $db->sql_fetchrow($result);
$submenu = $row['submenu'];
if($submenu != "") {
include("../header.php");
OpenTable();
echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b></center>";
CloseTable();
menu_adds($sub_id);
OpenTable();
echo"<center><b>"._THEMENU."</b></center>";
CloseTable();
include("../footer.php");
exit();
} else {
$ok = intval($_GET['ok']);
if($ok==1) {
$sub_id = $row['sub_id'];
if($sub_id!='0') {
$resultsub3 = $db->sql_query("SELECT submenu FROM ".$prefix."_nvmenu WHERE id='$sub_id'");
$rowsub3 = $db->sql_fetchrow($resultsub3);
$submenu3 = $rowsub3['submenu'];
$submenu3_array = explode("|",$submenu3);
$xsubmenu3 = "";
for($i=0;$i < sizeof($submenu3_array);$i++) {
if($submenu3_array[$i]!="$id") {
if($xsubmenu3=="") { $xsubmenu3 .= "$submenu3_array[$i]"; }
else { $xsubmenu3 .= "|$submenu3_array[$i]"; }
}
}
$db->sql_query("UPDATE ".$prefix."_nvmenu SET submenu = '$xsubmenu3'  WHERE id = '$sub_id'");
}
$db->sql_query("DELETE FROM ".$prefix."_nvmenu WHERE id = '$id'");
fixweightcatmenu();
Header("Location: ".$adminfile.".php?op=nvmenu_main");
} else {
include("../header.php");
OpenTable();
echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b></center>";
CloseTable();
menu_adds($sub_id);
OpenTable();
echo"<center><b>"._THEMENU2."</b><br><br>";
echo"<a href='".$adminfile.".php?op=menu_del&id=$id&ok=1'>"._DELETE."</a> | <a href='".$adminfile.".php?op=nvmenu_main'>"._NO."</a></center>";
CloseTable();
include("../footer.php");
exit();
}
}
}

function menu_pos() {
    global $prefix, $db;
    $id = intval($_GET['id']);
    $vt = intval($_GET['vt']);
    list($sub_id, $olweight) = $db->sql_fetchrow($db->sql_query("SELECT sub_id, weight FROM ".$prefix."_nvmenu WHERE id = '$id'"));
    list($id2, $newweight) = $db->sql_fetchrow($db->sql_query("SELECT id, weight FROM ".$prefix."_nvmenu WHERE sub_id = '$sub_id' order by weight LIMIT $vt,1"));
    $db->sql_query("UPDATE ".$prefix."_nvmenu SET weight = '$newweight'  WHERE id='$id'");
    $db->sql_query("UPDATE ".$prefix."_nvmenu SET weight = '$olweight'  WHERE id='$id2'");
    
    fixweightcatmenu();
    Header("Location: $_SERVER[HTTP_REFERER]");
}

function nvmenu_main() {
global $adminfile, $prefix, $db, $multilingual, $language;
    $sub_id = ( isset($_GET['sub_id']) ) ? intval($_GET['sub_id']) : 0;
    include("../header.php");
    OpenTable();
    echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b><br><br>"
    ."<a href='".$adminfile.".php?op=nvmenu_config'><b>"._CONFIGNVMENU."</b></a><----->"
    ."<a href='".$adminfile.".php?op=themmenu'><b>"._THEMMENU."</b></a></center>";
    CloseTable();
    //menu_adds($sub_id);
    $catnum = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM ".$prefix."_nvmenu WHERE sub_id = '$sub_id'"));
    if ($catnum[0] > 0) {
        OpenTable();
        if ($sub_id != '0') {
        list($c_catid, $title) = $db->sql_fetchrow($db->sql_query("SELECT sub_id, title FROM ".$prefix."_nvmenu WHERE id = '$sub_id'"));
        if($c_catid != '0') {
        $title = get_subid($c_catid, $title, 2);
        }
        echo"<center><b><a href=".$adminfile.".php?op=nvmenu_main>"._NVMENU1."</a> | $title</b></center><br><br>";
        } else {
        echo"<center><b>"._NVMENU1."</b></center><br><br>";
        }
        echo "<table border=\"1\" bordercolor=\"#000000\" cellpadding=\"3\" cellspacing=\"3\" width=\"100%\" style=\"border-collapse: collapse\">\n";
        echo "<tr>\n";
        echo "<td align=\"center\"><b>"._MENUNAME."</b></td>\n";
        echo "<td align=\"center\"><b>"._POSITION."</b></td>\n";
        echo "<td align=\"center\"><b>"._LANGUAGE."</b></td>\n";
        echo "<td align=\"center\"><b>"._FUNCTIONS."</b></td>\n";
        echo "</tr>\n";
        list($weighttest) = $db->sql_fetchrow($db->sql_query("SELECT max(weight) AS weighttest FROM ".$prefix."_nvmenu WHERE sub_id = '$sub_id'"));
        list($weighttest1) = $db->sql_fetchrow($db->sql_query("SELECT min(weight) AS weighttest1 FROM ".$prefix."_nvmenu WHERE sub_id = '$sub_id'"));
        $resultcat = $db->sql_query("select * from ".$prefix."_nvmenu WHERE sub_id = '$sub_id' order by weight");
        $a=0;
        while ($row = $db->sql_fetchrow($resultcat)) {
        $aa=$a+1;
        $ab=$a-1;
            if($catnum[0] < 2) {
                $p_pic = "&nbsp;";
            } else {
                if($row['weight'] == $weighttest1) {
                     $p_pic = "<a href=".$adminfile.".php?op=menu_pos&id=$row[id]&vt=$aa><img src=\"../images/down.gif\" alt=\""._CATDOWN."\" title=\""._CATDOWN."\" border=\"0\" hspace=\"3\"></a>\n";
                } else if($row['weight'] == $weighttest) {
                	 $p_pic = "<a href=".$adminfile.".php?op=menu_pos&id=$row[id]&vt=$ab><img src=\"../images/up.gif\" alt=\""._CATUP."\" title=\""._CATUP."\" border=\"0\" hspace=\"3\"></a>\n";
                } else {
                     $p_pic = "<a href=".$adminfile.".php?op=menu_pos&id=$row[id]&vt=$aa><img src=\"../images/down.gif\" alt=\""._CATDOWN."\" title=\""._CATDOWN."\" border=\"0\" hspace=\"3\"></a>&nbsp;<a href=".$adminfile.".php?op=menu_pos&id=$row[id]&sub_id=$sub_id&vt=$ab><img src=\"../images/up.gif\" alt=\""._CATUP."\" title=\""._CATUP."\" border=\"0\" hspace=\"3\"></a>\n";
                }
            }
            if($row['submenu'] != "") {
            $funct = "<a href=\"".$adminfile.".php?op=menu_edit&id=$row[id]\">"._EDIT."</a> | <a href=\"".$adminfile.".php?op=menu_del&id=$row[id]\">"._DELETE."</a> | <a href=\"".$adminfile.".php?op=nvmenu_main&sub_id=$row[id]\">"._VIEWSUBMENU."</a>";
            } else {
            $funct = "<a href=\"".$adminfile.".php?op=menu_edit&id=$row[id]\">"._EDIT."</a> | <a href=\"".$adminfile.".php?op=menu_del&id=$row[id]\">"._DELETE."</a>";
            }
            $menu_lang = $row['view_lang'];
            if($row['view_lang'] == "") { $menu_lang = ""._ALL.""; }
            echo "<tr>\n";
            echo "<td>$row[title]</td>\n";
            echo "<td align=\"center\">$p_pic</td>\n";
            echo "<td align=\"center\">$menu_lang</td>\n";
            echo "<td align=\"center\">$funct</td>\n";
            echo "</tr>\n";
            $a++;
        }
        
        echo"</table>\n";
        CloseTable();
    }
    echo "<br>";
    echo "<br><center><b><a href='http://thamtunamviet.com'>Converted by XMAN</a></b></center>";
include("../footer.php");
}

function optiontextalign($a,$b) {
if($b == 0) $align_ar = array(left,center,right);
elseif($b == 1) $align_ar = array(top,middle,bottom);
$option = "";
for($i=0;$i < 3;$i++) {
$option .= "<option value=\"$i\"";
if($a == $i) $option .= " selected";
$option .= ">$align_ar[$i]</option>\n";
}
return $option;
}

function optionborderst($c) {
$bord_ar = array('----','solid','double','dotted','dashed','groove','ridge','outset','inset');
$option = "";
for($i=0;$i < 8;$i++) {
$option .= "<option value=\"$i\"";
if($c == $i) $option .= " selected";
$option .= ">$bord_ar[$i]</option>\n";
}
return $option;
}
function themmenu() {
global $adminfile, $prefix, $db;
include("../includes/data/nvm_skin.php");
    include("../header.php");
    OpenTable();
    echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b><br><br>"
    ."<a href='".$adminfile.".php?op=nvmenu_config'><b>"._CONFIGNVMENU."</b></a><----->"
    ."<a href='".$adminfile.".php?op=themmenu'><b>"._THEMMENU."</b></a></center>";
   
        menu_adds($sub_id);
echo "<br><center><b><a href='http://thamtunamviet.com'>Converted by XMAN</a></b></center>";
}
function nvmenu_config() {
global $adminfile, $prefix, $db;
include("../includes/data/nvm_skin.php");
    include("../header.php");
    OpenTable();
    echo"<center><b><a href='".$adminfile.".php?op=nvmenu_main'>"._ADMINNVMENU."</a></b></center>";
    CloseTable();
    //menu_adds($sub_id);
    OpenTable();
echo "<form method=\"POST\" action=\"".$adminfile.".php\">\n";
echo "<table border=\"0\" cellpadding=\"0\" style=\"border-collapse: collapse\" width=\"100%\">\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\"><b>"._NVMCONF1."</b></td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\">&nbsp;</td>\n</tr>\n";
echo "<tr>\n<td valign='top'>"._NVMCONF2."</td>\n";
echo "<td valign='top'><input type=\"checkbox\" name=\"activnvmenu\" value=\"1\"";
if($activnvmenu == 1) echo " checked";
echo "></td>\n<td valign='top'>"._NVMCONF3."</td><td valign='top'>";
echo  "<select name='mdefault[]' multiple size='5'>";
echo "<option value=''>-------------</option>";
$result = $db->sql_query("select id, title from ".$prefix."_nvmenu WHERE sub_id = '0' order by weight");
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']); $title = $row['title'];
echo "<option value='$id'";
$xmdefault = explode("|",$mdefault);
if(in_array($id,$xmdefault)) { echo " selected"; }
echo ">$title</option>";
}
echo "</select>";
echo "</td>\n</tr>\n<tr>\n<td>"._NVMCONF4."</td>\n";
echo "<td><input type=\"checkbox\" name=\"popupview\" value=\"1\"";
if($popupview == 1) echo " checked";
echo "></td>\n<td><input type=\"hidden\" name=\"dvmenu\" value=\"0\">"._NVMCONF5."</td>\n";
echo "<td><select name=\"popupdirection\">";
$direct = array(Auto,Left,Right,Up,Down);
for($v=0;$v < 5;$v++) {
echo "<option value=\"$v\"";
if($popupdirection == $v) { echo " selected"; }
echo ">$direct[$v]</option>";
}
echo"</select></td>\n</tr>\n";
echo "<tr>\n<td>"._NVMCONF6."</td>\n";
echo "<td><input type=\"checkbox\" name=\"clpopup\" value=\"1\"";
if($clpopup == 1) echo " checked";
echo "></td>\n<td>"._NVMCONF7."</td>\n";
echo "<td><select size=\"1\" name=\"alignmenu\">\n";
echo optiontextalign($alignmenu,0);
echo "</select></td>\n</tr>\n";
echo "<tr>\n<td>"._NVMCONF8." (ms)</td>\n";
echo "<td><input type=\"text\" name=\"deleytimey\" size=\"10\" value='$deleytimey'></td>\n";
echo "<td>"._NVMCONF9." (ms)</td>\n<td><input type=\"text\" name=\"deleytimex\" size=\"10\" value='$deleytimex'></td>\n</tr>\n";
echo "<tr>\n<td>"._NVMCONF10." (ms)</td>\n<td><input type=\"text\" name=\"hidesubtime\" size=\"10\" value='$hidesubtime'></td>\n";
echo "<td>"._NVMCONF11."<br>"._NVMCONF51."</td>\n<td><select size=\"1\" name=\"displaymenu\">\n";
$cd = array(Horizontally,Vertically);
for($i=0;$i < 2;$i++) {
echo "<option value=\"$i\"";
if($displaymenu == $i) echo " selected";
echo ">$cd[$i]</option>\n";
}
echo "</select>\n";
echo "<br><select size=\"1\" name=\"displaysubmenu\">\n";
for($i=0;$i < 2;$i++) {
echo "<option value=\"$i\"";
if($displaysubmenu == $i) echo " selected";
echo ">$cd[$i]</option>\n";
}
echo "</select>\n";
echo "</td>\n</tr>\n";
echo "<tr>\n<td>"._NVMCONF12." (X)</td>\n<td><input type=\"text\" name=\"xcoordinate\" size=\"10\" value='$xcoordinate'></td>\n";
echo "<td>"._NVMCONF12." (Y)</td>\n<td><input type=\"text\" name=\"ycoordinate\" size=\"10\" value='$ycoordinate'></td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\">&nbsp;</td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\"><b>"._NVMCONF19."</b></td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\">&nbsp;</td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\">\n<table border=\"1\" cellpadding=\"0\" style=\"border-collapse: collapse\" width=\"100%\">\n";
echo "<tr>\n<td>&nbsp;</td>\n<td align=\"center\">"._NVMCONF13."</td>\n<td align=\"center\">"._NVMCONF14."</td>\n<td align=\"center\">"._NVMCONF15."</td>\n<td align=\"center\">"._NVMCONF16."</td>\n<td align=\"center\">"._NVMCONF17."</td>\n<td align=\"center\">"._NVMCONF18."</td>\n</tr>\n";

echo "<tr>\n<td>"._NVMCONF20."</td>\n";
$hang1name = array('textalignx_ca','textalignx_cn','textalignx_p1a','textalignx_p1n','textalignx_p2a','textalignx_p2n');
$hang1value = array($textalignx_ca,$textalignx_cn,$textalignx_p1a,$textalignx_p1n,$textalignx_p2a,$textalignx_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\"><select name=\"".$hang1name[$a]."\">\n";
echo optiontextalign($hang1value[$a],0);
echo "</select></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF21."</td>\n";
$hang2name = array('textaligny_ca','textaligny_cn','textaligny_p1a','textaligny_p1n','textaligny_p2a','textaligny_p2n');
$hang2value = array($textaligny_ca,$textaligny_cn,$textaligny_p1a,$textaligny_p1n,$textaligny_p2a,$textaligny_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\"><select name=\"".$hang2name[$a]."\">\n";
echo optiontextalign($hang2value[$a],1);
echo "</select></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF22."</td>\n";
$hang3name = array('bgcolorout_ca','bgcolorout_cn','bgcolorout_p1a','bgcolorout_p1n','bgcolorout_p2a','bgcolorout_p2n');
$hang3value = array($bgcolorout_ca,$bgcolorout_cn,$bgcolorout_p1a,$bgcolorout_p1n,$bgcolorout_p2a,$bgcolorout_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang3name[$a]."\" size=\"15\" value=\"".$hang3value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF23."</td>\n";
$hang4name = array('bgcolorover_ca','bgcolorover_cn','bgcolorover_p1a','bgcolorover_p1n','bgcolorover_p2a','bgcolorover_p2n');
$hang4value = array($bgcolorover_ca,$bgcolorover_cn,$bgcolorover_p1a,$bgcolorover_p1n,$bgcolorover_p2a,$bgcolorover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang4name[$a]."\" size=\"15\" value=\"".$hang4value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF24."</td>\n";
$hang5name = array('borderstyle_ca','borderstyle_cn','borderstyle_p1a','borderstyle_p1n','borderstyle_p2a','borderstyle_p2n');
$hang5value = array($borderstyle_ca,$borderstyle_cn,$borderstyle_p1a,$borderstyle_p1n,$borderstyle_p2a,$borderstyle_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\"><select name=\"".$hang5name[$a]."\">\n";
echo optionborderst($hang5value[$a]);
echo "</select></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF25." (px)</td>\n";
$hang6name = array('borderwidth_ca','borderwidth_cn','borderwidth_p1a','borderwidth_p1n','borderwidth_p2a','borderwidth_p2n');
$hang6value = array($borderwidth_ca,$borderwidth_cn,$borderwidth_p1a,$borderwidth_p1n,$borderwidth_p2a,$borderwidth_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang6name[$a]."\" size=\"15\" value=\"".$hang6value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF26."</td>\n";
$hang7name = array('bordertop_ca','bordertop_cn','bordertop_p1a','bordertop_p1n','bordertop_p2a','bordertop_p2n');
$hang7value = array($bordertop_ca,$bordertop_cn,$bordertop_p1a,$bordertop_p1n,$bordertop_p2a,$bordertop_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang7name[$a]."\" size=\"15\" value=\"".$hang7value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF27."</td>\n";
$hang8name = array('borderright_ca','borderright_cn','borderright_p1a','borderright_p1n','borderright_p2a','borderright_p2n');
$hang8value = array($borderright_ca,$borderright_cn,$borderright_p1a,$borderright_p1n,$borderright_p2a,$borderright_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang8name[$a]."\" size=\"15\" value=\"".$hang8value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF28."</td>\n";
$hang9name = array('borderbot_ca','borderbot_cn','borderbot_p1a','borderbot_p1n','borderbot_p2a','borderbot_p2n');
$hang9value = array($borderbot_ca,$borderbot_cn,$borderbot_p1a,$borderbot_p1n,$borderbot_p2a,$borderbot_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang9name[$a]."\" size=\"15\" value=\"".$hang9value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF29."</td>\n";
$hang10name = array('borderleft_ca','borderleft_cn','borderleft_p1a','borderleft_p1n','borderleft_p2a','borderleft_p2n');
$hang10value = array($borderleft_ca,$borderleft_cn,$borderleft_p1a,$borderleft_p1n,$borderleft_p2a,$borderleft_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang10name[$a]."\" size=\"15\" value=\"".$hang10value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF30."</td>\n";
$hang11name = array('bordertopover_ca','bordertopover_cn','bordertopover_p1a','bordertopover_p1n','bordertopover_p2a','bordertopover_p2n');
$hang11value = array($bordertopover_ca,$bordertopover_cn,$bordertopover_p1a,$bordertopover_p1n,$bordertopover_p2a,$bordertopover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang11name[$a]."\" size=\"15\" value=\"".$hang11value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF31."</td>\n";
$hang12name = array('borderrightover_ca','borderrightover_cn','borderrightover_p1a','borderrightover_p1n','borderrightover_p2a','borderrightover_p2n');
$hang12value = array($borderrightover_ca,$borderrightover_cn,$borderrightover_p1a,$borderrightover_p1n,$borderrightover_p2a,$borderrightover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang12name[$a]."\" size=\"15\" value=\"".$hang12value[$a]."\"></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF32."</td>\n";
$hang13name = array('borderbotover_ca','borderbotover_cn','borderbotover_p1a','borderbotover_p1n','borderbotover_p2a','borderbotover_p2n');
$hang13value = array($borderbotover_ca,$borderbotover_cn,$borderbotover_p1a,$borderbotover_p1n,$borderbotover_p2a,$borderbotover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang13name[$a]."\" size=\"15\" value='".$hang13value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF33."</td>\n";
$hang14name = array('borderleftover_ca','borderleftover_cn','borderleftover_p1a','borderleftover_p1n','borderleftover_p2a','borderleftover_p2n');
$hang14value = array($borderleftover_ca,$borderleftover_cn,$borderleftover_p1a,$borderleftover_p1n,$borderleftover_p2a,$borderleftover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang14name[$a]."\" size=\"15\" value='".$hang14value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF34."</td>\n";
$hang15name = array('fontcolorout_ca','fontcolorout_cn','fontcolorout_p1a','fontcolorout_p1n','fontcolorout_p2a','fontcolorout_p2n');
$hang15value = array($fontcolorout_ca,$fontcolorout_cn,$fontcolorout_p1a,$fontcolorout_p1n,$fontcolorout_p2a,$fontcolorout_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang15name[$a]."\" size=\"15\" value='".$hang15value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF35."</td>\n";
$hang16name = array('fontcolorover_ca','fontcolorover_cn','fontcolorover_p1a','fontcolorover_p1n','fontcolorover_p2a','fontcolorover_p2n');
$hang16value = array($fontcolorover_ca,$fontcolorover_cn,$fontcolorover_p1a,$fontcolorover_p1n,$fontcolorover_p2a,$fontcolorover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang16name[$a]."\" size=\"15\" value='".$hang16value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF36."</td>\n";
$hang17name = array('fontsizestyle_ca','fontsizestyle_cn','fontsizestyle_p1a','fontsizestyle_p1n','fontsizestyle_p2a','fontsizestyle_p2n');
$hang17value = array($fontsizestyle_ca,$fontsizestyle_cn,$fontsizestyle_p1a,$fontsizestyle_p1n,$fontsizestyle_p2a,$fontsizestyle_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang17name[$a]."\" size=\"15\" value='".$hang17value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF37."</td>\n";
$hang18name = array('fontsizestyleover_ca','fontsizestyleover_cn','fontsizestyleover_p1a','fontsizestyleover_p1n','fontsizestyleover_p2a','fontsizestyleover_p2n');
$hang18value = array($fontsizestyleover_ca,$fontsizestyleover_cn,$fontsizestyleover_p1a,$fontsizestyleover_p1n,$fontsizestyleover_p2a,$fontsizestyleover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang18name[$a]."\" size=\"15\" value='".$hang18value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF38."</td>\n";
$hang19name = array('itemwidth_ca','itemwidth_cn','itemwidth_p1a','itemwidth_p1n','itemwidth_p2a','itemwidth_p2n');
$hang19value = array($itemwidth_ca,$itemwidth_cn,$itemwidth_p1a,$itemwidth_p1n,$itemwidth_p2a,$itemwidth_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang19name[$a]."\" size=\"15\" value='".$hang19value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF39."</td>\n";
$hang20name = array('itemheight_ca','itemheight_cn','itemheight_p1a','itemheight_p1n','itemheight_p2a','itemheight_p2n');
$hang20value = array($itemheight_ca,$itemheight_cn,$itemheight_p1a,$itemheight_p1n,$itemheight_p2a,$itemheight_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang20name[$a]."\" size=\"15\" value='".$hang20value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF40." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang21name = array('imgleft_ca','imgleft_cn','imgleft_p1a','imgleft_p1n','imgleft_p2a','imgleft_p2n');
$hang21value = array($imgleft_ca,$imgleft_cn,$imgleft_p1a,$imgleft_p1n,$imgleft_p2a,$imgleft_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang21name[$a]."\" size=\"15\" value='".$hang21value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF41." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang22name = array('imgleftover_ca','imgleftover_cn','imgleftover_p1a','imgleftover_p1n','imgleftover_p2a','imgleftover_p2n');
$hang22value = array($imgleftover_ca,$imgleftover_cn,$imgleftover_p1a,$imgleftover_p1n,$imgleftover_p2a,$imgleftover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang22name[$a]."\" size=\"15\" value='".$hang22value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF42."</td>\n";
$hang23name = array('imglwidth_ca','imglwidth_cn','imglwidth_p1a','imglwidth_p1n','imglwidth_p2a','imglwidth_p2n');
$hang23value = array($imglwidth_ca,$imglwidth_cn,$imglwidth_p1a,$imglwidth_p1n,$imglwidth_p2a,$imglwidth_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang23name[$a]."\" size=\"15\" value='".$hang23value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF43."</td>\n";
$hang24name = array('imglheight_ca','imglheight_cn','imglheight_p1a','imglheight_p1n','imglheight_p2a','imglheight_p2n');
$hang24value = array($imglheight_ca,$imglheight_cn,$imglheight_p1a,$imglheight_p1n,$imglheight_p2a,$imglheight_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang24name[$a]."\" size=\"15\" value='".$hang24value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF44." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang25name = array('imgright_ca','imgright_cn','imgright_p1a','imgright_p1n','imgright_p2a','imgright_p2n');
$hang25value = array($imgright_ca,$imgright_cn,$imgright_p1a,$imgright_p1n,$imgright_p2a,$imgright_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang25name[$a]."\" size=\"15\" value='".$hang25value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF45." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang26name = array('imgrightover_ca','imgrightover_cn','imgrightover_p1a','imgrightover_p1n','imgrightover_p2a','imgrightover_p2n');
$hang26value = array($imgrightover_ca,$imgrightover_cn,$imgrightover_p1a,$imgrightover_p1n,$imgrightover_p2a,$imgrightover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang26name[$a]."\" size=\"15\" value='".$hang26value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF46."</td>\n";
$hang27name = array('imgrwidth_ca','imgrwidth_cn','imgrwidth_p1a','imgrwidth_p1n','imgrwidth_p2a','imgrwidth_p2n');
$hang27value = array($imgrwidth_ca,$imgrwidth_cn,$imgrwidth_p1a,$imgrwidth_p1n,$imgrwidth_p2a,$imgrwidth_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang27name[$a]."\" size=\"15\" value='".$hang27value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF47."</td>\n";
$hang28name = array('imgrheight_ca','imgrheight_cn','imgrheight_p1a','imgrheight_p1n','imgrheight_p2a','imgrheight_p2n');
$hang28value = array($imgrheight_ca,$imgrheight_cn,$imgrheight_p1a,$imgrheight_p1n,$imgrheight_p2a,$imgrheight_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang28name[$a]."\" size=\"15\" value='".$hang28value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF48." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang29name = array('bgimage_ca','bgimage_cn','bgimage_p1a','bgimage_p1n','bgimage_p2a','bgimage_p2n');
$hang29value = array($bgimage_ca,$bgimage_cn,$bgimage_p1a,$bgimage_p1n,$bgimage_p2a,$bgimage_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang29name[$a]."\" size=\"15\" value='".$hang29value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td>"._NVMCONF49." (<font color=\"#FF0000\">*</font>)</td>\n";
$hang30name = array('bgimageover_ca','bgimageover_cn','bgimageover_p1a','bgimageover_p1n','bgimageover_p2a','bgimageover_p2n');
$hang30value = array($bgimageover_ca,$bgimageover_cn,$bgimageover_p1a,$bgimageover_p1n,$bgimageover_p2a,$bgimageover_p2n);
for($a=0;$a < 6;$a++) {
echo "<td align=\"center\">\n<input type=\"text\" name=\"".$hang30name[$a]."\" size=\"15\" value='".$hang30value[$a]."'></td>\n";
}
echo "</tr>\n<tr>\n<td colspan=\"7\"><i>(<font color=\"#FF0000\">*</font>) : "._NVMCONF50."</i></td>\n</tr>\n";
echo "</table>\n</td>\n</tr>\n<tr>\n<td colspan=\"4\" align=\"center\">&nbsp;</td>\n</tr>\n";
echo "<tr>\n<td colspan=\"4\" align=\"center\"><input type='hidden' name='op' value='nvmenu_configsave'><input type=\"submit\" value=\""._SAVE."\"></td>\n</tr>\n</table>\n</form>\n";
    CloseTable();
    echo "<br><center><b><a href='http://thamtunamviet.com'>Converted by XMAN</a></b></center>";
}

function nvmenu_configsave() {
 global $adminfile;
	@chmod("../includes/data/nvm_skin.php", 0777);
	@$file = fopen("../includes/data/nvm_skin.php", "w");

    if (!$file) {
    include("../header.php");
    OpenTable();
    echo "<br><center><b>"._ERORSAVE."</b><br>"._ERORSAVETEXT.": includes/data/nvm_skin.php</center><br>";
    CloseTable();
    include("../footer.php");
    exit;
    }
    
    $line = "########################################\n";

    $content = "<?php\n\n";
    $content .= "/*-----NVMenu module for NUKEVIET PRO-----*/\n/*-- Copyright (C) 2005-2010 Nukeviet Groups.--*/\n/*---------------All Rights Reserved-------------------*/\n/*------------Email: info@nukeviet.org---------------*/\n/*--------Website: http://www.nukeviet.org----------*/\n";
    $content .= "\n";
    $content .= "$line\n";
    $content .= "\$activnvmenu = ".intval($_POST[activnvmenu]).";\n";
    $xmdefault = implode("|",$_POST[mdefault]);
    $content .= "\$mdefault = \"".$xmdefault."\";\n";
    $content .= "\$popupview = ".intval($_POST[popupview]).";\n";
    $content .= "\$dvmenu = ".intval($_POST[dvmenu]).";\n";
    $content .= "\$clpopup = ".intval($_POST[clpopup]).";\n";
    $content .= "\$alignmenu = ".intval($_POST[alignmenu]).";\n";
    $content .= "\$deleytimey = ".intval($_POST[deleytimey]).";\n";
    $content .= "\$deleytimex = ".intval($_POST[deleytimex]).";\n";
    $content .= "\$hidesubtime = ".intval($_POST[hidesubtime]).";\n";
    $content .= "\$displaymenu = ".intval($_POST[displaymenu]).";\n";
    $content .= "\$displaysubmenu = ".intval($_POST[displaysubmenu]).";\n";
    $content .= "\$xcoordinate = ".intval($_POST[xcoordinate]).";\n";
    $content .= "\$ycoordinate = ".intval($_POST[ycoordinate]).";\n";
    $content .= "\$popupdirection = ".intval($_POST[popupdirection]).";\n";
    $content .= "\$effectshow = \"\";\n";
    $content .= "\$effecthid = \"\";\n";
    $content .= "\n";
    $content .= "$line\n";
    $a_ar = array("\$textalignx_ca","\$textalignx_cn","\$textalignx_p1a","\$textalignx_p1n","\$textalignx_p2a","\$textalignx_p2n",
    					    "\$textaligny_ca","\$textaligny_cn","\$textaligny_p1a","\$textaligny_p1n","\$textaligny_p2a","\$textaligny_p2n",
    					    "\$bgcolorout_ca","\$bgcolorout_cn","\$bgcolorout_p1a","\$bgcolorout_p1n","\$bgcolorout_p2a","\$bgcolorout_p2n",
    					    "\$bgcolorover_ca","\$bgcolorover_cn","\$bgcolorover_p1a","\$bgcolorover_p1n","\$bgcolorover_p2a","\$bgcolorover_p2n",
    					    "\$borderstyle_ca","\$borderstyle_cn","\$borderstyle_p1a","\$borderstyle_p1n","\$borderstyle_p2a","\$borderstyle_p2n",
    					    "\$borderwidth_ca","\$borderwidth_cn","\$borderwidth_p1a","\$borderwidth_p1n","\$borderwidth_p2a","\$borderwidth_p2n",
    					    "\$bordertop_ca","\$bordertop_cn","\$bordertop_p1a","\$bordertop_p1n","\$bordertop_p2a","\$bordertop_p2n",
    					    "\$borderright_ca","\$borderright_cn","\$borderright_p1a","\$borderright_p1n","\$borderright_p2a","\$borderright_p2n",
    					    "\$borderbot_ca","\$borderbot_cn","\$borderbot_p1a","\$borderbot_p1n","\$borderbot_p2a","\$borderbot_p2n",
    					    "\$borderleft_ca","\$borderleft_cn","\$borderleft_p1a","\$borderleft_p1n","\$borderleft_p2a","\$borderleft_p2n",
    					    "\$bordertopover_ca","\$bordertopover_cn","\$bordertopover_p1a","\$bordertopover_p1n","\$bordertopover_p2a","\$bordertopover_p2n",
    					    "\$borderrightover_ca","\$borderrightover_cn","\$borderrightover_p1a","\$borderrightover_p1n","\$borderrightover_p2a","\$borderrightover_p2n",
    					    "\$borderbotover_ca","\$borderbotover_cn","\$borderbotover_p1a","\$borderbotover_p1n","\$borderbotover_p2a","\$borderbotover_p2n",
    					    "\$borderleftover_ca","\$borderleftover_cn","\$borderleftover_p1a","\$borderleftover_p1n","\$borderleftover_p2a","\$borderleftover_p2n",
    					    "\$fontcolorout_ca","\$fontcolorout_cn","\$fontcolorout_p1a","\$fontcolorout_p1n","\$fontcolorout_p2a","\$fontcolorout_p2n",
    					    "\$fontcolorover_ca","\$fontcolorover_cn","\$fontcolorover_p1a","\$fontcolorover_p1n","\$fontcolorover_p2a","\$fontcolorover_p2n",
    					    "\$fontsizestyle_ca","\$fontsizestyle_cn","\$fontsizestyle_p1a","\$fontsizestyle_p1n","\$fontsizestyle_p2a","\$fontsizestyle_p2n",
    					    "\$fontsizestyleover_ca","\$fontsizestyleover_cn","\$fontsizestyleover_p1a","\$fontsizestyleover_p1n","\$fontsizestyleover_p2a","\$fontsizestyleover_p2n",
    					    "\$itemwidth_ca","\$itemwidth_cn","\$itemwidth_p1a","\$itemwidth_p1n","\$itemwidth_p2a","\$itemwidth_p2n",
    					    "\$itemheight_ca","\$itemheight_cn","\$itemheight_p1a","\$itemheight_p1n","\$itemheight_p2a","\$itemheight_p2n",
    					    "\$imgleft_ca","\$imgleft_cn","\$imgleft_p1a","\$imgleft_p1n","\$imgleft_p2a","\$imgleft_p2n",
    					    "\$imgleftover_ca","\$imgleftover_cn","\$imgleftover_p1a","\$imgleftover_p1n","\$imgleftover_p2a","\$imgleftover_p2n",
    					    "\$imglwidth_ca","\$imglwidth_cn","\$imglwidth_p1a","\$imglwidth_p1n","\$imglwidth_p2a","\$imglwidth_p2n",
    					    "\$imglheight_ca","\$imglheight_cn","\$imglheight_p1a","\$imglheight_p1n","\$imglheight_p2a","\$imglheight_p2n",
    					    "\$imgright_ca","\$imgright_cn","\$imgright_p1a","\$imgright_p1n","\$imgright_p2a","\$imgright_p2n",
    					    "\$imgrightover_ca","\$imgrightover_cn","\$imgrightover_p1a","\$imgrightover_p1n","\$imgrightover_p2a","\$imgrightover_p2n",
    					    "\$imgrwidth_ca","\$imgrwidth_cn","\$imgrwidth_p1a","\$imgrwidth_p1n","\$imgrwidth_p2a","\$imgrwidth_p2n",
    					    "\$imgrheight_ca","\$imgrheight_cn","\$imgrheight_p1a","\$imgrheight_p1n","\$imgrheight_p2a","\$imgrheight_p2n",
    					    "\$bgimage_ca","\$bgimage_cn","\$bgimage_p1a","\$bgimage_p1n","\$bgimage_p2a","\$bgimage_p2n",
    					    "\$bgimageover_ca","\$bgimageover_cn","\$bgimageover_p1a","\$bgimageover_p1n","\$bgimageover_p2a","\$bgimageover_p2n");
    $b_ar = array(intval($_POST['textalignx_ca']),intval($_POST['textalignx_cn']),intval($_POST['textalignx_p1a']),intval($_POST['textalignx_p1n']),intval($_POST['textalignx_p2a']),intval($_POST['textalignx_p2n']),
    					    intval($_POST['textaligny_ca']),intval($_POST['textaligny_cn']),intval($_POST['textaligny_p1a']),intval($_POST['textaligny_p1n']),intval($_POST['textaligny_p2a']),intval($_POST['textaligny_p2n']),
    					    $_POST['bgcolorout_ca'],$_POST['bgcolorout_cn'],$_POST['bgcolorout_p1a'],$_POST['bgcolorout_p1n'],$_POST['bgcolorout_p2a'],$_POST['bgcolorout_p2n'],
    					    $_POST['bgcolorover_ca'],$_POST['bgcolorover_cn'],$_POST['bgcolorover_p1a'],$_POST['bgcolorover_p1n'],$_POST['bgcolorover_p2a'],$_POST['bgcolorover_p2n'],
    					    intval($_POST['borderstyle_ca']),intval($_POST['borderstyle_cn']),intval($_POST['borderstyle_p1a']),intval($_POST['borderstyle_p1n']),intval($_POST['borderstyle_p2a']),intval($_POST['borderstyle_p2n']),
    					    intval($_POST['borderwidth_ca']),intval($_POST['borderwidth_cn']),intval($_POST['borderwidth_p1a']),intval($_POST['borderwidth_p1n']),intval($_POST['borderwidth_p2a']),intval($_POST['borderwidth_p2n']),
    					    $_POST['bordertop_ca'],$_POST['bordertop_cn'],$_POST['bordertop_p1a'],$_POST['bordertop_p1n'],$_POST['bordertop_p2a'],$_POST['bordertop_p2n'],
    					    $_POST['borderright_ca'],$_POST['borderright_cn'],$_POST['borderright_p1a'],$_POST['borderright_p1n'],$_POST['borderright_p2a'],$_POST['borderright_p2n'],
    					    $_POST['borderbot_ca'],$_POST['borderbot_cn'],$_POST['borderbot_p1a'],$_POST['borderbot_p1n'],$_POST['borderbot_p2a'],$_POST['borderbot_p2n'],
    					    $_POST['borderleft_ca'],$_POST['borderleft_cn'],$_POST['borderleft_p1a'],$_POST['borderleft_p1n'],$_POST['borderleft_p2a'],$_POST['borderleft_p2n'],
    					    $_POST['bordertopover_ca'],$_POST['bordertopover_cn'],$_POST['bordertopover_p1a'],$_POST['bordertopover_p1n'],$_POST['bordertopover_p2a'],$_POST['bordertopover_p2n'],
    					    $_POST['borderrightover_ca'],$_POST['borderrightover_cn'],$_POST['borderrightover_p1a'],$_POST['borderrightover_p1n'],$_POST['borderrightover_p2a'],$_POST['borderrightover_p2n'],
    					    $_POST['borderbotover_ca'],$_POST['borderbotover_cn'],$_POST['borderbotover_p1a'],$_POST['borderbotover_p1n'],$_POST['borderbotover_p2a'],$_POST['borderbotover_p2n'],
    					    $_POST['borderleftover_ca'],$_POST['borderleftover_cn'],$_POST['borderleftover_p1a'],$_POST['borderleftover_p1n'],$_POST['borderleftover_p2a'],$_POST['borderleftover_p2n'],
    					    $_POST['fontcolorout_ca'],$_POST['fontcolorout_cn'],$_POST['fontcolorout_p1a'],$_POST['fontcolorout_p1n'],$_POST['fontcolorout_p2a'],$_POST['fontcolorout_p2n'],
    					    $_POST['fontcolorover_ca'],$_POST['fontcolorover_cn'],$_POST['fontcolorover_p1a'],$_POST['fontcolorover_p1n'],$_POST['fontcolorover_p2a'],$_POST['fontcolorover_p2n'],
    					    $_POST['fontsizestyle_ca'],$_POST['fontsizestyle_cn'],$_POST['fontsizestyle_p1a'],$_POST['fontsizestyle_p1n'],$_POST['fontsizestyle_p2a'],$_POST['fontsizestyle_p2n'],
    					    $_POST['fontsizestyleover_ca'],$_POST['fontsizestyleover_cn'],$_POST['fontsizestyleover_p1a'],$_POST['fontsizestyleover_p1n'],$_POST['fontsizestyleover_p2a'],$_POST['fontsizestyleover_p2n'],
    					    intval($_POST['itemwidth_ca']),intval($_POST['itemwidth_cn']),intval($_POST['itemwidth_p1a']),intval($_POST['itemwidth_p1n']),intval($_POST['itemwidth_p2a']),intval($_POST['itemwidth_p2n']),
    					    intval($_POST['itemheight_ca']),intval($_POST['itemheight_cn']),intval($_POST['itemheight_p1a']),intval($_POST['itemheight_p1n']),intval($_POST['itemheight_p2a']),intval($_POST['itemheight_p2n']),
    					    $_POST['imgleft_ca'],$_POST['imgleft_cn'],$_POST['imgleft_p1a'],$_POST['imgleft_p1n'],$_POST['imgleft_p2a'],$_POST['imgleft_p2n'],
    					    $_POST['imgleftover_ca'],$_POST['imgleftover_cn'],$_POST['imgleftover_p1a'],$_POST['imgleftover_p1n'],$_POST['imgleftover_p2a'],$_POST['imgleftover_p2n'],
    					    intval($_POST['imglwidth_ca']),intval($_POST['imglwidth_cn']),intval($_POST['imglwidth_p1a']),intval($_POST['imglwidth_p1n']),intval($_POST['imglwidth_p2a']),intval($_POST['imglwidth_p2n']),
    					    intval($_POST['imglheight_ca']),intval($_POST['imglheight_cn']),intval($_POST['imglheight_p1a']),intval($_POST['imglheight_p1n']),intval($_POST['imglheight_p2a']),intval($_POST['imglheight_p2n']),
    					    $_POST['imgright_ca'],$_POST['imgright_cn'],$_POST['imgright_p1a'],$_POST['imgright_p1n'],$_POST['imgright_p2a'],$_POST['imgright_p2n'],
    					    $_POST['imgrightover_ca'],$_POST['imgrightover_cn'],$_POST['imgrightover_p1a'],$_POST['imgrightover_p1n'],$_POST['imgrightover_p2a'],$_POST['imgrightover_p2n'],
    					    intval($_POST['imgrwidth_ca']),intval($_POST['imgrwidth_cn']),intval($_POST['imgrwidth_p1a']),intval($_POST['imgrwidth_p1n']),intval($_POST['imgrwidth_p2a']),intval($_POST['imgrwidth_p2n']),
    					    intval($_POST['imgrheight_ca']),intval($_POST['imgrheight_cn']),intval($_POST['imgrheight_p1a']),intval($_POST['imgrheight_p1n']),intval($_POST['imgrheight_p2a']),intval($_POST['imgrheight_p2n']),
    					    $_POST['bgimage_ca'],$_POST['bgimage_cn'],$_POST['bgimage_p1a'],$_POST['bgimage_p1n'],$_POST['bgimage_p2a'],$_POST['bgimage_p2n'],
    					    $_POST['bgimageover_ca'],$_POST['bgimageover_cn'],$_POST['bgimageover_p1a'],$_POST['bgimageover_p1n'],$_POST['bgimageover_p2a'],$_POST['bgimageover_p2n']);
    $c_ar = array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1);
    for($i=0;$i < 180;$i++) {
    	if($c_ar[$i]==0) {
    	$content .= "$a_ar[$i] = $b_ar[$i];\n";
    	} elseif($c_ar[$i] == 1) {
    	$content .= "$a_ar[$i] = \"$b_ar[$i]\";\n";
    	}
    	if ($i%6 == 5 AND $i < 179) $content .= "/*-------------------------------------------*/\n";
    }
    $content .= "\n";
    $content .= "$line\n";
    $content .= "if ((!defined('NV_SYSTEM')) AND (!defined('NV_ADMIN'))) {\n";
    $content .= "Header(\"Location: ../../index.php\");\n";
    $content .= "die();\n";
    $content .= "}\n";
    $content .= "\n";
    $content .= "?>\n";
    
    @$writefile = fwrite($file, $content);
    if (!$writefile) {
    include ("../header.php");
    OpenTable();
    echo "<br><br><br><center><b>"._ERORSAVE."</b>
    <br><br>"._ERORSAVEFILE1." includes/data/nvm_skin.php.<br><br><br></center>";
    CloseTable();
    include ("../footer.php");
    exit;
    }
    @fclose($file);
    @chmod("../includes/data/nvm_skin.php", 0604);

    Header("Location: ".$adminfile.".php?op=nvmenu_config");
}

switch ($op) {

case "menu_pos":
menu_pos();
break;

case "menu_addsave":
menu_addsave();
break;

case "menu_edit":
menu_edit();
break;

case "themmenu":
themmenu();
break;

case "menu_editsave":
menu_editsave();
break;

case "menu_del":
menu_del();
break;

case "nvmenu_main":
nvmenu_main();
break;

case "nvmenu_config":
nvmenu_config();
break;

case "nvmenu_configsave":
nvmenu_configsave();
break;

}

} else {
echo "Access Denied";
}

?>